﻿<controls:ChildWindow 
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
  xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
  xmlns:dataform="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.DataForm.Toolkit"
  xmlns:activity="clr-namespace:System.Windows.Controls;assembly=ActivityControl"
  xmlns:app="clr-namespace:CARE"
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  x:Class="CARE.LoginWindow"
  x:Name="childWindow"
  Width="410" 
  Title="Login"
  mc:Ignorable="d">
  
  <controls:ChildWindow.Resources>
    <Storyboard x:Name="ToLogin">
      <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="registerPanel" Storyboard.TargetProperty="(UIElement.Visibility)">
        <DiscreteObjectKeyFrame KeyTime="00:00:00">
          <DiscreteObjectKeyFrame.Value>
            <Visibility>Visible</Visibility>
          </DiscreteObjectKeyFrame.Value>
        </DiscreteObjectKeyFrame>
        <DiscreteObjectKeyFrame KeyTime="00:00:00.0750000">
        	<DiscreteObjectKeyFrame.Value>
        		<Visibility>Visible</Visibility>
        	</DiscreteObjectKeyFrame.Value>
        </DiscreteObjectKeyFrame>
        <DiscreteObjectKeyFrame KeyTime="00:00:00.1000000">
        	<DiscreteObjectKeyFrame.Value>
        		<Visibility>Collapsed</Visibility>
        	</DiscreteObjectKeyFrame.Value>
        </DiscreteObjectKeyFrame>
      </ObjectAnimationUsingKeyFrames>
      <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="registerPanel" Storyboard.TargetProperty="(UIElement.Opacity)">
        <EasingDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
        <EasingDoubleKeyFrame KeyTime="00:00:00.0750000" Value="0"/>
        <EasingDoubleKeyFrame KeyTime="00:00:00.1000000" Value="0"/>
      </DoubleAnimationUsingKeyFrames>
      <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="loginPanel" Storyboard.TargetProperty="(UIElement.Visibility)">
        <DiscreteObjectKeyFrame KeyTime="00:00:00">
          <DiscreteObjectKeyFrame.Value>
            <Visibility>Collapsed</Visibility>
          </DiscreteObjectKeyFrame.Value>
        </DiscreteObjectKeyFrame>
        <DiscreteObjectKeyFrame KeyTime="00:00:00.0750000">
        	<DiscreteObjectKeyFrame.Value>
        		<Visibility>Visible</Visibility>
        	</DiscreteObjectKeyFrame.Value>
        </DiscreteObjectKeyFrame>
      </ObjectAnimationUsingKeyFrames>
      <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="loginPanel" Storyboard.TargetProperty="(UIElement.Opacity)">
      	<EasingDoubleKeyFrame KeyTime="00:00:00.0750000" Value="0"/>
      	<EasingDoubleKeyFrame KeyTime="00:00:00.2000000" Value="1"/>
      </DoubleAnimationUsingKeyFrames>
    </Storyboard>
    <Storyboard x:Name="ToRegister">
        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="registerPanel" Storyboard.TargetProperty="(UIElement.Visibility)">
          <DiscreteObjectKeyFrame KeyTime="00:00:00.0750000">
        		<DiscreteObjectKeyFrame.Value>
        			<Visibility>Visible</Visibility>
        		</DiscreteObjectKeyFrame.Value>
        	</DiscreteObjectKeyFrame>
          <DiscreteObjectKeyFrame KeyTime="00:00:00.2500000">
          	<DiscreteObjectKeyFrame.Value>
          		<Visibility>Visible</Visibility>
          	</DiscreteObjectKeyFrame.Value>
          </DiscreteObjectKeyFrame>
        </ObjectAnimationUsingKeyFrames>
        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="loginPanel" Storyboard.TargetProperty="(UIElement.Opacity)">
          <EasingDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
          <EasingDoubleKeyFrame KeyTime="00:00:00.0750000" Value="0"/>
          <EasingDoubleKeyFrame KeyTime="00:00:00.1000000" Value="0"/>
        </DoubleAnimationUsingKeyFrames>
        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="loginPanel" Storyboard.TargetProperty="(UIElement.Visibility)">
          <DiscreteObjectKeyFrame KeyTime="00:00:00.0750000">
        		<DiscreteObjectKeyFrame.Value>
        			<Visibility>Visible</Visibility>
        		</DiscreteObjectKeyFrame.Value>
        	</DiscreteObjectKeyFrame>
          <DiscreteObjectKeyFrame KeyTime="00:00:00.1000000">
          	<DiscreteObjectKeyFrame.Value>
          		<Visibility>Collapsed</Visibility>
          	</DiscreteObjectKeyFrame.Value>
          </DiscreteObjectKeyFrame>
        </ObjectAnimationUsingKeyFrames>
        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="registerPanel" Storyboard.TargetProperty="(UIElement.Opacity)">
          <EasingDoubleKeyFrame KeyTime="00:00:00.0750000" Value="0"/>
          <EasingDoubleKeyFrame KeyTime="00:00:00.2500000" Value="1">
          	<EasingDoubleKeyFrame.EasingFunction>
          		<CubicEase EasingMode="EaseIn"/>
          	</EasingDoubleKeyFrame.EasingFunction>
          </EasingDoubleKeyFrame>
      </DoubleAnimationUsingKeyFrames>
    </Storyboard>
  </controls:ChildWindow.Resources>

	<controls:ChildWindow.Style>
		<StaticResource ResourceKey="LogRegWindowStyle"/>
	</controls:ChildWindow.Style>

  <Grid x:Name="LayoutRoot">
    <Grid.RowDefinitions>
      <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>

    <StackPanel x:Name="loginPanel" Grid.Row="0">
      <Grid>
        <Grid.RowDefinitions>
          <RowDefinition/>
          <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <StackPanel Style="{StaticResource LoginControlsStackPanelStyle}">
          <!-- username textbox-->
          <StackPanel Style="{StaticResource LoginControlStyle}">
            <TextBlock Text="Username" Style="{StaticResource LoginTextStyle}"/>
            <TextBox x:Name="loginUserNameBox" TextChanged="LoginUserNameBox_TextChanged" Style="{StaticResource LoginTextBoxStyle}" Text="test"/>
          </StackPanel>
          <!-- password textbox-->
          <StackPanel Style="{StaticResource LoginControlStyle}">
            <TextBlock Text="Password" Style="{StaticResource LoginTextStyle}"/>
            <PasswordBox x:Name="loginPasswordBox" PasswordChanged="LoginPasswordBox_PasswordChanged" Style="{StaticResource LoginPSBoxStyle}" Password="Password#1"/>
          </StackPanel>
        </StackPanel>

        <StackPanel Style="{StaticResource RegisterLoginLinkPanelStyle}" Grid.Row="1">
          <TextBlock Text="Not yet registered?" Style="{StaticResource CommentStyle}"/>
          <HyperlinkButton x:Name="registerNow" Content="Register Now" Click="RegisterNow_Click"/>
        </StackPanel>

        <Button Content="Cancel" Click="CancelButton_Click" Margin="0,0,0,1" Grid.Row="1" Style="{StaticResource RegisterLoginButtonStyle}"/>
        <Button x:Name="loginButton" Content="OK" Click="LoginButton_Click" Grid.Row="1" Style="{StaticResource RegisterLoginButtonStyle}"/>

      </Grid>
    </StackPanel>

    <StackPanel x:Name="registerPanel" Grid.Row="0" Visibility="Collapsed">
      <Grid>
        <Grid.RowDefinitions>
          <RowDefinition />
          <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <activity:Activity x:Name="activity">
          <dataform:DataForm x:Name="registerForm" Header="Please enter required information for account creation" AutoGenerateFields="False" AutoEdit="True" CommandButtonsVisibility="None" Grid.Row="0" Style="{StaticResource DataFormStyle}">
            <dataform:DataForm.EditTemplate>
              <DataTemplate>
                <StackPanel Orientation="Vertical">
                  <dataform:DataField Label="Username">
                    <TextBox Text="{Binding UserName, Mode=TwoWay}" />
                  </dataform:DataField>

                  <dataform:DataField Label="Password">
                    <app:PasswordControl PasswordText="{Binding Password, Mode=TwoWay}"/>
                  </dataform:DataField>

                  <dataform:DataField Label="Confirm password">
                    <app:PasswordControl PasswordText="{Binding ConfirmPassword, Mode=TwoWay}"/>
                  </dataform:DataField>

                  <dataform:DataField Label="Email">
                    <TextBox Text="{Binding Email, Mode=TwoWay}" />
                  </dataform:DataField>

                  <dataform:DataField Label="Question">
                    <TextBox Text="{Binding Question, Mode=TwoWay}" />
                  </dataform:DataField>

                  <dataform:DataField Label="Answer">
                    <TextBox Text="{Binding Answer, Mode=TwoWay}" />
                  </dataform:DataField>
                </StackPanel>
              </DataTemplate>
            </dataform:DataForm.EditTemplate>
          </dataform:DataForm>
        </activity:Activity>
        <StackPanel Style="{StaticResource RegisterLoginLinkPanelStyle}" Grid.Row="1">
          <TextBlock Text="Already registered?" Style="{StaticResource CommentStyle}" />
          <HyperlinkButton x:Name="backToLogin" Content="Back to Login" Click="BackToLogin_Click"/>
        </StackPanel>

        <Button Content="Cancel" Click="CancelButton_Click" Margin="0,0,0,1" Grid.Row="1" Style="{StaticResource RegisterLoginButtonStyle}"/>
        <Button x:Name="registerButton" Content="OK" Click="RegisterButton_Click" Grid.Row="1" Style="{StaticResource RegisterLoginButtonStyle}"/>

      </Grid>

    </StackPanel>

  </Grid>

</controls:ChildWindow>